﻿@model OASys.Web.Areas.ModuleWF.Models.ModelWorkFlowStepIndex
@{
	ViewBag.Title = "Index";
	Layout = "~/Views/Shared/_LayoutDialog.cshtml";
}
<style type="text/css">
	.container
	{
		text-align: center;
		margin-left: auto ;
		margin-right: auto ;
	}
	.node, .start
	{
		background-color: #C0D1E3;
		margin: 10px 10%;
		padding:5px 0;
		font-size:14px;
		font-weight:bold;
		color:White;
	}
	.arrow
	{
		padding:0;
		margin:0;
	}
</style>
<script type="text/javascript">
	$(function () {
		$.contextMenu({
			selector: '.node',
			callback: function (key, options) {
				var stepId = options.$trigger.attr("stepId");
				switch (key) {
					case "add":
						window.top.openDialog({ Index: 2, Url: "/ModuleWF/WorkFlowStep/Create/?CurrentStepId=" + stepId + "&flowid=@(Model.FlowID)", Title: "增加下级节点", Width: 400, Height: 200 });
						break;
					case "edit":
						window.top.openDialog({ Index: 2, Url: "/ModuleWF/WorkFlowStep/Edit/?id=" + stepId, Title: "编辑节点", Width: 400, Height: 200 });
						break;
					case "delete":
						top.window.$("#sysConfirm").html("确定要删除？");
						top.window.$("#sysConfirm").dialog({
							resizable: false,
							height: 200,
							title: "系统提示",
							modal: true,
							buttons: {
								"是": function () {
									$.ajax({
										type: "POST",
										url: "/ModuleWF/WorkFlowStep/Delete",
										data: "id=" + stepId,
										success: function (msg) {
											msg = eval("(" + msg + ")");
											if (msg.result == "") {
												window.location = window.location;
												window.top.showSysMessage();
											}
											else {
												window.top.sysAlert(msg.result);
											}
										}
									});
									top.window.$("#sysConfirm").dialog("close");
								},
								"否": function () {
									top.window.$("#sysConfirm").dialog("close");
								}
							}
						});
						break;
				}
			},
			items: {
				"edit": { name: "编辑节点", icon: "edit" },
				"add": { name: "增加下级节点", icon: "add" },
				"delete": { name: "删除节点", icon: "delete" },
				"sep1": "---------",
				"quit": { name: "关闭", icon: "quit" }
			}
		});

		$.contextMenu({
			selector: '.start',
			callback: function (key, options) {
				var stepId = options.$trigger.attr("stepId");
				switch (key) {
					case "add":
						window.top.openDialog({ Index: 2, Url: "/ModuleWF/WorkFlowStep/Create/?CurrentStepId=" + stepId + "&flowid=@(Model.FlowID)", Title: "增加下级节点", Width: 400, Height: 200 });
						break;
				}
			},
			items: {
				"add": { name: "增加下级节点", icon: "add" },
				"sep1": "---------",
				"quit": { name: "关闭", icon: "quit" }
			}
		});

	});



</script>
<div class="container">
	<div class="start">
		申请人
	</div>
	<div class="arrow">
			<img src="/content/images/arrow_mini_down.png" />
		</div>
	@{
		var step = Model.Steps.FirstOrDefault(x => x.NextStepID == null);
		var steps = new List<WFFlowSteps>();
	}
	@while (step != null)
 {
	 steps.Add(step);
	 step = Model.Steps.FirstOrDefault(x => x.NextStepID == step.ID);
 }
	@{steps.Reverse();}
	@for (int i = 0; i < steps.Count; i++)
 {
		<div class="node" stepId ="@(steps[i].ID)">
			@steps[i].StepName
		</div>
	 if (steps[i].NextStepID != null)
	 {
		<div class="arrow">
			<img src="/content/images/arrow_mini_down.png" />
		</div>
	 }
 }
</div>
